﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Diablo_Character_Simulator.Enumerators;

namespace Diablo_Character_Simulator
{
    class Character
    {
        public Inventory Inventory { get; private set; }
        private Class charClass;

        public Class Class
        {
            get { return this.charClass; }
            set
            {
                Reset();
                this.charClass = value;
                setBaseStats();
            }
        }

        public int BaseStrength { get; private set; }
        public int BaseVitality { get; private set; }
        public int BaseIntelligence { get; private set; }
        public int BaseDexterity { get; private set; }
        public int Level { get; private set; }

        public void AddItem(ItemSlot slot, List<ItemStat> stats, WeaponType weapType)
        {
            this.Inventory.Add(slot, stats, weapType);
        }

        public Character()
        {
            this.Inventory = new Inventory();
            this.charClass = Class.None;
            this.Level = 60;
        }

        private void Reset()
        {
            this.Inventory.Reset();
            this.charClass = Class.None;
            this.Level = 60;
            //TODO: reset UI
        }

        public static void OnItemUpdate()
        {
            //TODO: recalc
        }

        private void setBaseStats()
        {
            this.BaseStrength = ClassHelper.GetBaseStat(charClass, StatType.Strength, Level);
            this.BaseVitality = ClassHelper.GetBaseStat(charClass, StatType.Vitality, Level);
            this.BaseDexterity = ClassHelper.GetBaseStat(charClass, StatType.Dexterity, Level);
            this.BaseIntelligence = ClassHelper.GetBaseStat(charClass, StatType.Intelligence, Level);
        }
    }
}
